package com.scott.ch090;

import com.scott.ch090.prize.Prize;
import com.scott.ch090.prize.impl.Book;
import com.scott.ch090.prize.impl.Pad;
import com.scott.ch090.prize.impl.Phone;

import java.sql.Array;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2021-12-18 16:25:14
 */
public class Client {

    public static void main(String[] args) {

        // 抽奖品
        // PrizeUtil<Prize>
        ch1();

        // 抽奖金
        // PrizeUtil<Integer>
        ch2();

        // 使用静态的泛型方法抽奖金
        // PrizeUtil<Integer>
        ch3();

        System.out.println("---------------------------");
        // 使用静态的扩展泛型方法抽奖金
        // PrizeUtil<Integer>
        ch4();



    }

    private static void ch4(){
        // 拿到抽奖工具
        List<Integer> moneyList= new ArrayList<>();
        moneyList.add(100);
        moneyList.add(200);
        moneyList.add(500);
        moneyList.add(1000);

        // 来 模拟1次抽奖
//        Integer prize = PrizeUtil.getPrize4(moneyList,"scott",23);
//        Integer prize = PrizeUtil.getPrize4(moneyList,1.3f,true);
        Integer prize = PrizeUtil.getPrize4(moneyList,2.5,Client.class);
        System.out.println("恭喜你、抽中奖金 "+prize+" 元");

    }

    private static void ch3(){
        // 拿到抽奖工具
        List<Integer> moneyList= new ArrayList<>();
        moneyList.add(100);
        moneyList.add(200);
        moneyList.add(500);
        moneyList.add(1000);

        // 来 模拟1次抽奖
        Integer prize = PrizeUtil.getPrize3(moneyList);
        System.out.println("恭喜你、抽中奖金 "+prize+" 元");



    }

    private static void ch2(){
        // 拿到抽奖工具
        PrizeUtil<Integer> prizeUtil = new PrizeUtil<>();

        List<Integer> moneyList= new ArrayList<>();
        moneyList.add(100);
        moneyList.add(200);
        moneyList.add(500);
        moneyList.add(1000);

        // 来 模拟1次抽奖
        Integer prize = prizeUtil.getPrize2(moneyList);
        System.out.println("恭喜你、抽中奖金 "+prize+" 元");

        prizeUtil.getData(moneyList);

    }


    private static  void ch1(){
        // 拿到抽奖工具
        PrizeUtil<Prize> prizeUtil = new PrizeUtil<>();

        // 初始化奖品
        List<Prize> prizeList =  initPrize();

        // 把奖品添加到抽奖工具中
        for (Prize prize : prizeList) {
            prizeUtil.addPrize(prize);
        }

        // 来 模拟1次抽奖
        Prize prize = prizeUtil.getPrize2(prizeList);
        System.out.println("恭喜你、抽中奖品 "+prize.getPrizeName());

    }

    private static List<Prize> initPrize(){
        Prize phone = new Phone();
        Prize pad   = new Pad();
        Prize book = new Book();
        List<Prize> list = new ArrayList<>();
        list.add(phone);
        list.add(pad);
        list.add(book);
        return list;

    }
}
